package com.woniuxy.email.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ConfirmConfig {

    //创建交换机
    @Bean
    public DirectExchange confirmExchange() {
        return new DirectExchange("confirm.direct.exchange");
    }

    //创建队列
    @Bean
    public Queue confirmQueue() {
        return new Queue("confirm.queue");
    }

    //队列绑定到交换机
    @Bean
    public Binding confirmToDirectExchange(Queue confirmQueue, DirectExchange confirmExchange) {
        return BindingBuilder.bind(confirmQueue).to(confirmExchange).with("msg.confirm");
    }
}